import { Collider2D, Component, Contact2DType, EventKeyboard, IPhysics2DContact, Input, KeyCode, Node, NodeEventType, Tween, Vec3, _decorator, input } from "cc";

const { ccclass, property } = _decorator;


@ccclass("House")
export class House extends Component {

    protected onEnable(): void {
        let collider2D = this.node.getComponent(Collider2D);
        collider2D.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this)
        collider2D.on(Contact2DType.END_CONTACT, this.onEndContact, this)
    }

    protected onDisable(): void {
        let collider2D = this.node.getComponent(Collider2D);
        collider2D.off(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this)
        collider2D.off(Contact2DType.END_CONTACT, this.onEndContact, this)
    }

    onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
        console.log('onBeginContact' + otherCollider.node.name);
    }

    onEndContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
        console.log('onEndContact' + otherCollider.node.name);
    }


}